/*
 * @Author: darkgoldenrod(暮秋)
 * @Date: 2022-04-18 16:57:30
 * @LastEditTime: 2022-04-22 16:59:09
 * @LastEditors: darkgoldenrod(暮秋)
 * @Description: 
 * @FilePath: \vue_咸鱼\spuertalkl\src\utils\echartutil.js
 */

import * as echarts from "echarts";

export function topleft(text,datas){
    var option = {
        title:{
          text:text,
          left: 'center'
        },
        tooltip: {},
        series: [
          {
            type: "wordCloud",
            gridSize: 2,
            sizeRange: [12, 50],
            rotationRange: [-90, 90],
            shape: "pentagon",
            width: 600,
            height: 400,
            drawOutOfBound: true,
            textStyle: {
              color: function () {
                return (
                  "rgb(" +
                  [
                    Math.round(Math.random() * 160),
                    Math.round(Math.random() * 160),
                    Math.round(Math.random() * 160),
                  ].join(",") +
                  ")"
                );
              },
            },
            emphasis: {
              textStyle: {
                shadowBlur: 10,
                shadowColor: "#333",
              },
            },
            data: datas
          },
        ],
      };
      return option;
}

export function topmiddle(datas){
    return{
      title: {
        text: '点赞数最多的十条微博',
        subtext: 'Top 10 most-liked tweets',
        left: 'center'
      },
      xAxis: {
        type: 'category',
        data: datas[0],
        axisLabel: { interval: 0, rotate: 30 }
      },
      yAxis: {
        type: 'value'
      },
      tooltip: {
        trigger: 'item',
        formatter:" {b} {c}"
      },
      series: [
        {
          data: datas[1],
          type: 'bar',
          showBackground: true,
          backgroundStyle: {
            color: 'rgba(180, 180, 180, 0.2)'
          }
        }
      ]
    };
}

export function topright(datas){
    var option = {
        title: {
          text: '性别分布',
          subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter:" {b} {c}({d}%)"
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: datas,
            label: {
              show: true,
              position: 'outside',
              formatter: '{b} {d}%'
            },
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
    return option
}

// 发布微博数量最多的用户 z柱状图
export function buttonleft(datas){
    return {
      title: {
        text: '超话中所有微博最多的点赞数及用户',
        left: 'center'
      },
      tooltip: {
        trigger: 'item',
        formatter: '{b} : {c}%'
      },
      legend: {
        type:"scroll",
        left:"right",
        top:100,
        orient: 'vertical',
        data: ['Show', 'Click', 'Visit', 'Inquiry', 'Order']
      },
      series: [
        {
          name: 'Funnel',
          type: 'funnel',
          left: '10%',
          top: 60,
          bottom: 60,
          width: '80%',
          min: 0,
          max: 100,
          minSize: '0%',
          maxSize: '100%',
          sort: 'descending',
          gap: 2,
          label: {
            show: true,
            position: 'inside',
            formatter: '{b} {c}'
          },
          labelLine: {
            length: 10,
            lineStyle: {
              width: 1,
              type: 'solid'
            }
          },
          itemStyle: {
            borderColor: '#fff',
            borderWidth: 1
          },
          emphasis: {
            label: {
              fontSize: 20
            }
          },
          data: 
          // [
          //   { value: 60, name: 'Visit' },
          //   { value: 40, name: 'Inquiry' },
          //   { value: 20, name: 'Order' },
          //   { value: 80, name: 'Click' },
          //   { value: 100, name: 'Show' }
          // ]
          datas[2]
        }
      ]
    };
}

export function buttonmiddle(datas){
   return {
    legend: {
      top: 'bottom'
    },
    title: {
      text: '超话中微博评论数最多的用户',
      left: 'center'
    },
    series: [
      {
        name: 'Nightingale Chart',
        type: 'pie',
        radius: [50, 250],
        center: ['50%', '50%'],
        roseType: 'area',
        itemStyle: {
          borderRadius: 8
        },
        label: {
          show: true,
          position: 'outside',
          formatter: '{b}({c})'
        },
        data: 
        // [
        //   { value: 40, name: 'rose 1' },
        //   { value: 38, name: 'rose 2' },
        //   { value: 32, name: 'rose 3' },
        //   { value: 30, name: 'rose 4' },
        //   { value: 28, name: 'rose 5' },
        //   { value: 26, name: 'rose 6' },
        //   { value: 22, name: 'rose 7' },
        //   { value: 18, name: 'rose 8' }
        // ]
        datas
      }
    ]
  };
}


export function ttopmiddle(datas){
  return {
    title:{
      text:"发微博最多的用户",
      left:"center"
    },
    tooltip: {
      trigger: 'item'
    },
    dataset: [
      {
        dimensions: ['name', 'value'],
        source: 
        datas
        // [
        //   ['Hannah Krause', 41, 'Engineer', 314, '2011-02-12'],
        //   ['Zhao Qian', 20, 'Teacher', 351, '2011-03-01'],
        //   ['Jasmin Krause ', 52, 'Musician', 287, '2011-02-14'],
        //   ['Li Lei', 37, 'Teacher', 219, '2011-02-18'],
        //   ['Karle Neumann', 25, 'Engineer', 253, '2011-04-02'],
        //   ['Adrian Groß', 19, 'Teacher', '-', '2011-01-16'],
        //   ['Mia Neumann', 71, 'Engineer', 165, '2011-03-19'],
        //   ['Böhm Fuchs', 36, 'Musician', 318, '2011-02-24'],
        //   ['Han Meimei', 67, 'Engineer', 366, '2011-03-12']
        // ]
      },
      {
        transform: {
          type: 'sort',
          config: { dimension: 'value', order: 'desc' }
        }
      }
    ],
    xAxis: {
      type: 'category',
      axisLabel: { interval: 0, rotate: 30 }
    },
    yAxis: {},
    series: {
      type: 'bar',
      encode: { x: 'name', y: 'value' },
      datasetIndex: 1
    }
  };
}

export function ttopright(datas){
  return {
    title: {
      text: '男女比例分布',
      subtext: 'Gender distribution',
      left: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'vertical',
      left: 'left'
    },
    series: [
      {
        name: 'Access From',
        type: 'pie',
        radius: '50%',
        data: datas
        // [
        //   { value: 1048, name: 'Search Engine' },
        //   { value: 735, name: 'Direct' },
        //   { value: 580, name: 'Email' },
        //   { value: 484, name: 'Union Ads' },
        //   { value: 300, name: 'Video Ads' }
        // ]
        ,
        label: {
          show: true,
          position: 'outside',
          formatter: '{b} {d}%'
        },
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  };
}

export function bbuttonleft(datas){

const colors = ['#5470C6', '#91CC75', '#EE6666'];
return {
  color: colors,
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross'
    }
  },
  title: {
    text: '随机用户信息'
  },
  grid: {
    right: '20%'
  },
  legend: {
    type:"scroll",
    left:250,
    data: ["微博数","关注数","粉丝数"]
  },
  xAxis: [
    {
      type: 'category',
      axisTick: {
        alignWithLabel: true
      },
      axisLabel: { interval: 0, rotate: 30 },
      // prettier-ignore
      data: datas[0]
    }
  ],
  yAxis: [
    {
      type: 'value',
      name: '关注数',
      position: 'right',
      alignTicks: true,
      axisLine: {
        show: true,
        lineStyle: {
          color: colors[0]
        }
      },
      axisLabel: {
        formatter: '{value}'
      }
    },
    {
      type: 'value',
      name: '粉丝数',
      position: 'right',
      alignTicks: true,
      offset: 80,
      axisLine: {
        show: true,
        lineStyle: {
          color: colors[0]
        }
      },
      axisLabel: {
        formatter: '{value}'
      }
    },
    {
      type: 'value',
      name: '微博数',
      position: 'left',
      alignTicks: true,
      axisLine: {
        show: true,
      },
      axisLabel: {
        formatter: '{value}'
      }
    }
  ],
  series: [
    {
      name: '微博数',
      type: 'bar',
      yAxisIndex: 2,
      data: datas[1]
    },
    {
      name: '关注数',
      type: 'line',
      data: datas[2]
    }
    ,
    {
      name: '粉丝数',
      yAxisIndex: 1,
      type: 'line',
      data: datas[3]
    }
  ]
};
return option

}

export function tbuttonmiddle(datas){
  return {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        // Use axis to trigger tooltip
        type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
      }
    },
    title:{
      text:"评论最多的是十条微博和它们的转发数点赞数",
      left:"center"
    },
    legend: {
      orient: 'vertical',
      left:"right"
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'value'
    },
    yAxis: {
      type: 'category',
      data: datas[0]
    },
    series: [
      {
        name: '评论数',
        type: 'bar',
        stack: 'total',
        label: {
          show: true
        },
        emphasis: {
          focus: 'series'
        },
        data: datas[1]
      },
      {
        name: '点赞数',
        type: 'bar',
        stack: 'total',
        label: {
          show: true
        },
        emphasis: {
          focus: 'series'
        },
        data: datas[2]
      },
      {
        name: '转发数',
        type: 'bar',
        stack: 'total',
        label: {
          show: true
        },
        emphasis: {
          focus: 'series'
        },
        data: datas[3]
      },
    ]
  };
}